package vn.conghuy.talkwithme.responsor.action;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

/**
 * 
 * @author conghuy
 * NOTE:
 * Need SetObjectToCall
 *
 */
public class CallAction extends Action {
	
	/**
	 * @uml.property  name="address"
	 */
	String address = "";

	public CallAction(Context context, String address) {
		super(context);
		this.address = address;
	}
	
	@Override
	public void doAction() {
		if(address.equals("")) return;
		try {
	        Intent callIntent = new Intent(Intent.ACTION_CALL);
	        callIntent.setData(Uri.parse("tel:"+address));
	        context.startActivity(callIntent);
	    } catch (ActivityNotFoundException e) {
	        Log.e("DEBUG", "Call failed", e);
	    }
		super.doAction();
		address = "";
	}
}
